import React from 'react'
import { bindActionCreators } from 'redux'
import withRedux from 'next-redux-wrapper'
import { getUserInfo } from '../store/user.redux'
import { initTotalStore } from '../store/store'
import Head from '../components/Head'
import Nav from '../components/Nav/Nav'
import ContentLeft from '../components/Content/ContentLeft'
import ContentRight from '../components/Content/ContentRight'
import AntdLayout from '../components/AntdLayout'

import '../static/common.css'

class index extends React.Component {
    constructor(props) {
        super(props)
    }

    componentWillMount() {
        this.props.getUserInfo()
    }

    render() {
        return (
            <AntdLayout>
                <div className="background index">
                    <Head title="Home" />
                    <Nav searchShow={true} />
                    <div className="background content">
                        <ContentLeft />
                        <ContentRight />
                    </div>
                    <style jsx>{`
                        .index {
                            min-height:100%;
                            background-color: #f6f6f6;
                        }
                        .content {
                            display: flex;
                            margin: 0 auto;
                            max-width: 1024px;
                            min-height: 100%;
                            padding-top: 55px;
                        }
                    `}</style>
                </div>
            </AntdLayout>
        )
    }
}

const mapDispatchToProps = (dispatch) => {
    return {
        getUserInfo: bindActionCreators(getUserInfo, dispatch)
    }
}
export default withRedux(initTotalStore, null, mapDispatchToProps)(index)